{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<h3>特征预处理</h3>\n",
       "<span><strong>\n",
       "归一化<br>&nbsp&nbsp\n",
       "概念:通过对原始数据进行变换把数据映射到默认[0,1]区间内<img src=\"1-02.png\">\n",
       "作用于每一列,max为一列的最大值,min为一列的最小值,那么X''为最终结果,mx,mi 分别指定区间值默认mx=1,mi=0\n",
       "</strong></span>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html\n",
    "<h3>特征预处理</h3>\n",
    "<span><strong>\n",
    "归一化<br>&nbsp&nbsp\n",
    "概念:通过对原始数据进行变换把数据映射到默认[0,1]区间内<img src=\"1-02.png\">\n",
    "作用于每一列,max为一列的最大值,min为一列的最小值,那么X''为最终结果,mx,mi 分别指定区间值默认mx=1,mi=0\n",
    "</strong></span>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<span><strong>公式应用</strong><img src=\"01-05.png\"></span>\n",
       "<text><strong>\n",
       "    X' = 90-60 / 90-60 = 1<br><br>\n",
       "    X''= 1 * 1 + 0 = 1  \n",
       "</strong></text>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html\n",
    "<span><strong>公式应用</strong><img src=\"01-05.png\"></span>\n",
    "<text><strong>\n",
    "    X' = 90-60 / 90-60 = 1<br><br>\n",
    "    X''= 1 * 1 + 0 = 1  \n",
    "</strong></text>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[2.44832535, 2.39805139, 2.56233353],\n",
       "       [2.15873259, 2.34195467, 2.98724416],\n",
       "       [2.28542943, 2.06892523, 2.47449629],\n",
       "       ...,\n",
       "       [2.29115949, 2.50910294, 2.51079493],\n",
       "       [2.52711097, 2.43665451, 2.4290048 ],\n",
       "       [2.47940793, 2.3768091 , 2.78571804]])"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"\n",
    "sklearn.prepocessing.MinMaxScalar( feature_range(0,1))\n",
    "    MinMaxScalar.fit_transform(X)\n",
    "        x:numpy array 格式数据[n_simple,n_feature]\n",
    "    返回值:转换后形状相同的array\n",
    "\n",
    "\"\"\"\n",
    "import pandas as pd\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "# 获取数据\n",
    "data = pd.read_csv(\"dating.txt\")\n",
    "data = data.iloc[:,:3]\n",
    "# 实例化转换器\n",
    "transfer = MinMaxScaler( feature_range = (2,3))\n",
    "# 调用fit_transform\n",
    "data_new = transfer.fit_transform( data )\n",
    "data_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
